﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data.SqlClient;
using System.Linq;
using System.Windows.Forms;
using Microsoft.Win32.SafeHandles;
using OpenSoftStore.Orm;
using OpenSoftStore.Orm.Model;
using OpenSoftStore.Orm.Static;

namespace OpenSoftStore.BusinessLogic.Common
{
    public class LoginLogic : ABusinessLogic
    {
        #region Methods

        public Boolean Login(string name,string pass)
        {
            //if (string.IsNullOrEmpty(pass)) return false;
            //&& m.Pass == pass
            List<T_Admin> admins = Spa.Where<T_Admin>(m => m.Name == name && m.Pass == pass).ToList();
            if (!admins.Any()) return false;
            S_Admin.Id = admins.First().Id;
            S_Admin.Name = admins.First().Name;
            S_Admin.ShopId = admins.First().ShopId;
            S_Admin.TreeId = admins.First().TreeId;
            S_Admin.Address = admins.First().Address;
            return true;
        }

        #endregion
    }
}

